<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<head>
    <meta charset="utf-8" />
    <title>祈贝健康--后台管理系统</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />

    <!-- ================== BEGIN BASE CSS STYLE ================== -->
    <link href="./Public/Admin/assets/plugins/jquery-ui/themes/base/minified/jquery-ui.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/animate.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/style.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/style-responsive.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/theme/default.css" rel="stylesheet" id="theme" />
    <!-- ================== END BASE CSS STYLE ================== -->

    <!-- ================== BEGIN PAGE LEVEL STYLE ================== -->
    <link href="./Public/Admin/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />
    <!-- ================== END PAGE LEVEL STYLE ================== -->

    <!-- ================== BEGIN BASE JS ================== -->
    <script src="./Public/Admin/assets/plugins/pace/pace.min.js"></script>
    <!-- ================== END BASE JS ================== -->
</head>
<body>
<php> include './Public/Admin/header.html'; </php>



<!-- begin #content -->
<div id="content" class="content">
    <!-- begin breadcrumb -->
    <ol class="breadcrumb pull-right">
        <li><a href="javascript:;">首页</a></li>
        <li><a href="javascript:;">商铺商品管理</a></li>
        <li class="active">修改商铺商品</li>

    </ol>
    <!-- end breadcrumb -->
    <!-- begin page-header -->
    <h1 class="page-header">商铺商品 <small>修改商铺商品</small></h1>
    <!-- end page-header -->

    <!-- begin row -->
    <div class="row">
        <!-- begin col-12 -->
        <div class="col-md-12">
            <!-- begin panel -->
            <div class="panel panel-inverse">
                <div class="panel-heading">
                    <div class="panel-heading-btn">
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-repeat"></i></a>
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-danger" data-click="panel-remove"><i class="fa fa-times"></i></a>
                    </div>
                    <h4 class="panel-title">修改商铺</h4>
                </div>
                <div class="panel-body">
                    <div class="table-responsive">
                        <!--表单-->

                        <div class='col-md-10'>
                            <form class='form-horizontal' role='form' method="post" action="index.php?m=Admin&c=ShopBase&a=actionUpdate" enctype="multipart/form-data">

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>商铺类别：</label>
                                    <div class='col-md-4'>
                                        <select  class='form-control' name="lib" id="lib">


                                        </select>
                                    </div>
                                </div>

                                <!--<div class='form-group'>-->
                                    <!--<label for='inputtext' class='col-md-2 control-label'>商户名称：</label>-->
                                    <!--<div class='col-md-4'>-->
                                        <!--<input type='text' class='form-control input-lg' name="sid" id='sid' placeholder='请输入商户名称'>-->
                                    <!--</div>-->
                                <!--</div>-->

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>商铺名称：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="name" id='name' placeholder='请输入商铺名称'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>商铺英文名称：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="en_name" id='en_name' placeholder='请输入商铺英文名称'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>中文简介：</label>
                                    <div class='col-md-4'>
                                        <textarea class="form-control" rows='3' name="cn_abstract" id="cn_abstract"  placeholder="请输入英文文介绍"></textarea>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>输入英文简介：</label>
                                    <div class='col-md-4'>
                                        <textarea class="form-control" rows='3' name="en_abstract" id="en_abstract"  placeholder="请输入英文文介绍"></textarea>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>地址：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="addr" id='addr' placeholder='请输入商铺地址'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>服务标准：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="standards" id='standards' placeholder='标准服务'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>生活说明：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="life_description" id='life_description' placeholder='请输生活说明'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>特色服务：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="characteristic" id='characteristic' placeholder='请输入特色服务'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>免费和赠品：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="gift" id='gift' placeholder='请输生活说明'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>不包含服务：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="not_contain" id='not_contain' placeholder='请输入不包含的服务'>
                                    </div>
                                </div>


                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>所属国家：</label>
                                    <div class='col-md-4'>
                                        <select onchange="loadCity()" class='form-control' name="cid" id="cid">


                                        </select>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>所属城市：</label>
                                    <div class='col-md-4'>
                                        <select class='form-control' name="zid" id="zid">


                                        </select>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label' id="test">logo图：</label>

                                </div>


                                <div class='form-group' id="addInput">
                                    <label for='inputtext' class='col-md-2 control-label'>商品形图</label>
                                    <div class='col-md-4'>
                                        &nbsp;&nbsp;&nbsp;&nbsp;<a id="but" class="btn btn-primary">加</a>
                                    </div>

                                </div>
                                <div class='form-group' id="addImg">
                                    <label for='inputtext' class='col-md-2 control-label'>photo</label>

                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>币种：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="bz" id='bz' placeholder='请输入币种'>
                                    </div>
                                </div>



                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>是否合作：</label>
                                    <div class='col-md-2'>
                                        <input type='checkbox' class='form-control input-lg' name="is_hz" id='is_hz' value="1">如果是合作商请在此打 " √ "
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>是否最新：</label>
                                    <div class='col-md-2'>
                                        <input type='checkbox' class='form-control input-lg' name="is_new" id='is_new' value="1">如果是最新请在此打" √ "
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>平台手续费：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="pay_percentage" id='pay_percentage' placeholder='请输入平台手续费'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>用户手续费：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="u_poundage" id='u_poundage' placeholder='请输入用户手续费'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>联系方式：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="information" id='information' placeholder='请输入联系方式'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>联系人姓名：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="username" id='username' placeholder='请输入联系人'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>营业开始时间：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="bh_start" id='bh_start' placeholder='请输入营业开始时间'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>营业结束时间：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="bh_stop" id='bh_stop' placeholder='请输入营业结束时间'>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>是否全日开放：</label>
                                    <div class='col-md-2'>
                                        <input type='checkbox' class='form-control input-lg' name="is_bh" id='is_bh' value="1">如果是合作商请在此打 " √ "
                                    </div>
                                </div>
                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>经度：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="lat" id='lat' placeholder='请输入经度'>
                                    </div>
                                </div>


                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>备注：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="remark" id='remark' placeholder='请输入备注'>
                                    </div>
                                </div>


                                <div class='form-group'>
                                    <div class='col-md-3 col-md-offset-2'>
                                        <button onclick="" class='btn btn-success btn-radius form-control'>提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>

                    </div>
                    </div>
            </div>
            <!-- end panel -->
        </div>
        <!-- end col-12 -->
    </div>
    <!-- end row -->
</div>
<!-- end #content -->


<!-- begin scroll to top btn -->
<a href="javascript:;" class="btn btn-icon btn-circle btn-success btn-scroll-to-top fade" data-click="scroll-top"><i class="fa fa-angle-up"></i></a>
<!-- end scroll to top btn -->
<?php include './header.html'; ?>
<!-- end page container -->

<!-- ================== BEGIN BASE JS ================== -->
<script src="./Public/Admin/assets/plugins/jquery/jquery-1.9.1.min.js"></script>
<script src="./Public/Admin/assets/plugins/jquery/jquery-migrate-1.1.0.min.js"></script>
<script src="./Public/Admin/assets/plugins/jquery-ui/ui/minified/jquery-ui.min.js"></script>
<script src="./Public/Admin/assets/plugins/bootstrap/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="./Public/Admin/assets/crossbrowserjs/html5shiv.js"></script>
<script src="./Public/Admin/assets/crossbrowserjs/respond.min.js"></script>
<script src="./Public/Admin/assets/crossbrowserjs/excanvas.min.js"></script>
<![endif]-->
<script src="./Public/Admin/assets/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<!-- ================== END BASE JS ================== -->

<!-- ================== BEGIN PAGE LEVEL JS ================== -->
<script src="./Public/Admin/assets/plugins/DataTables/js/jquery.dataTables.js"></script>
<script src="./Public/Admin/assets/plugins/DataTables/js/dataTables.colVis.js"></script>
<script src="./Public/Admin/assets/js/apps.min.js"></script>
<!-- ================== END PAGE LEVEL JS ================== -->
<script>


$(document).ready(function() {

        App.init();
        loadc();


    });
    var dataNum=-1;
     var lid;
     var cid;
     var zid;
    function loadc(){

        $.getJSON("index.php?m=Admin&c=ShopBase&a=update_list",function(result){
            if(result!=0){
                lid=result.lid;
                cid=result.cid;
                zid=result.zid;
                $("#name").val(result.name);
                $("#en_name").val(result.en_name);
                $("#phone").val(result.phone);
                $("#cn_abstract").val(result.cn_abstract);
                $("#en_abstract").val(result.en_abstract);
                $("#standards").val(result.standards);
                $("#life_description").val(result.life_description);
                $("#characteristic").val(result.characteristic);
                $("#gift").val(result.gift);
                $("#not_contain").val(result.not_contain);
                $("#pay_percentage").val(result.pay_percentage);
                $("#u_poundage").val(result.u_poundage);
                $("#information").val(result.information);
                $("#username").val(result.username);
                $("#bh_start").val(result.bh_start);
                $("#bh_stop").val(result.bh_stop);
                $("#lat").val(result.lat);
                $("#lng").val(result.lng);
                $("#remark").val(result.remark);
                if(result.is_hz){
                    $("#is_new").attr("checked","checked");
                }
                if(result.is_hz){
                    $("#is_hz").attr("checked","checked");
                }
                if(result.is_bh){
                    $("#is_bh").attr("checked","checked");
                }

                $("#update_time").val(result.update_time);
                //=================================当在显示页面点击编辑时，商品logo的呈现==================================================
                var  html=" ";
                html+= '<div id="display_img" class="col-xs-6 col-md-2"><a href="#" class="thumbnail"><img src="./imageShopBaseLog/' +result.logo_img + '"></a>';
                html+='<div class="col-md-5">&nbsp;&nbsp;<div class="col-md-8"><a class="btn btn-success" id="updateLogo" onclick="update()" >删除</a></div>'


            }
            $("#test").after(html);

            $.getJSON("index.php?m=Admin&c=ShopBase&a=get_shop_class",function(result){
                var html='<option value="-1">--请选择--</option>';
                if(result!=null){
                    $.each(result, function(key, val) {
                        if(lid==val.id){
                            html+='<option value="'+val.id+'" selected>'+val.name+'</option>';
                        }else{
                            html+='<option value="'+val.id+'">'+val.name+'</option>';
                        }

                    });
                }
                $("#lib").html(html);
            });



            /*=======================获取国家信息==========================*/
            $.getJSON("index.php?m=Admin&c=ShopBase&a=get_country_list",function(result) {
                var html = '<option value="-1">--请选择--</option>';
                if (result != null) {
                    $.each(result, function (key, val) {
                        if (cid == val.countryid) {
                            html += '<option value="' + val.countryid + '" selected>' + val.countryname_cn + '</option>';
                        } else {
                            html += '<option value="' + val.countryid + '">' +val.countryname_cn + '</option>';
                        }
                    });
                }
                $("#cid").html(html);

                //=============================在数据库里取出数据，用于显示修改前的地区
                $.getJSON("index.php?m=Admin&c=ShopBase&a=get_city_one&zid="+zid,function(result) {
                    var html = '';
                    if (result != null) {
                        html += '<option value="' + result.id + '">' + result.name + '</option>';
                    }
                    $("#zid").html(html);
                });

            });

        });






        //======================================获取并处理形象图==============================================
        $.getJSON("index.php?m=Admin&c=ShopBase&a=get_imgs_list",function(result){
            if(result!=0){
                var getNum=result.length-1;
                dataNum=getNum;
                for(var i=0; i<=getNum; i++){
                    var showHtml= '<div  class="form-group" id="imgs'+i+'">';
                    showHtml+="<label for='inputtext' class='col-md-2 control-label'></label>";
                    showHtml+= '<div class="col-xs-6 col-md-2"><a href="#" class="thumbnail"><img src="./imageShopBase/'+result[i] +'"></a>';
                    showHtml+='<div class="col-md-5">&nbsp;&nbsp;<div class="col-md-8"><a class="btn btn-success" id="del'+i+'" onclick="del('+"'"+result[i]+"',"+i+')" >删除</a></div></div></div>';
                    $("#addImg").after(showHtml);
                }
            }
        });
    }
    //===========================================修改商品Logo图===============================================
    function update(){
        var logoHtml="<div  class='col-md-4' id='logo_img'>";
        logoHtml+= '<input type="file" name="logo_img" id="display_img"/>';
        logoHtml += "</div>";
        $("#display_img").html(logoHtml);

        //要考虑删除图片的逻辑
    }

    //===================================增加图片上传表单=====================================
    $("#but").click(function(){

        if(dataNum<4){
            dataNum++;
            var newRow='<div  class="col-md-4 col-md-offset-2"><input type="file" name="imgs[]" id="inputImage'+dataNum+'"/></div>';
            newRow+='<div class="col-md-2"><a class="btn btn-success" id="inputDel'+dataNum+'" onclick="inputDel('+dataNum+')" >删除</a></div>';
            $("#addInput").after(newRow);

        }

    });
    //========================删除修改显示的图片===========================
    function del(obj,obj1){
        $.getJSON("index.php?m=Admin&c=ShopBase&a=update_imgs&imgNum="+obj1,function(result){
            dataNum--;
            if(result!=0){
                $("#imgs"+obj).remove();
            }

        });
    }
    //============================删除添加表单的==================================
    function inputDel(obj){
        dataNum--;
        $("#inputImage"+obj).remove();
        $("#inputDel"+obj).remove();
    }



    function loadCity(){
        var a=$("#cid").find("option:selected").val();
        $.getJSON("index.php?m=Admin&c=ShopBase&a=get_city_list&cid="+a,function(result){
            var html = '<option value="-1">--请选择--</option>';
            if(result!=null){
                $.each(result,function(key,val){
                    html += '<option value="' + val.id + '">' + val.name + '</option>';
                });
            }
            $("#zid").html(html);
        });
    }

</script>


</body>
</html>

